<template>
  <view class="root">
    <view class="content">
      <yy-scroll-view :static-params="staticParams" ref="scrllViewRef" request-url="/mini/wb/wbmedicinerecords/page"
        :auto-request="false">
        <template slot-scope="{list}">
          <view class="care-item" v-for="(item, index) in list" :key="index" @click="handleItem(item)">
            <view class="item-title">
              {{moment(item.helpTime).format('MM月DD日')}} *吃药记录*
            </view>
            <view class="item-i">
              <view class="item-label">
                药品名称:
              </view>
              <view class="item-value">
                {{item.medicine_name}}
              </view>
            </view>
            <view class="item-i">
              <view class="item-label">
                吃药时间:
              </view>
              <view class="item-value">
                {{
                moment(item.help_time).format('YYYY/MM/DD HH:mm')
                }}
              </view>
            </view>
            <view class="item-i">
              <view class="item-label">
                吃药地点:
              </view>
              <view class="item-value">
                {{item.help_address}}
              </view>
            </view>
          </view>
        </template>
      </yy-scroll-view>
    </view>
    <!--    <view class="bottom">
      <u-button text="新增吃药记录" :custom-style="halfColorButton"></u-button>
    </view> -->
    <yy-watermark></yy-watermark>
  </view>
</template>

<script>
  import {
    navTo,
    halfColorButton,
    getOptionsParams
  } from '@/utils/util.js'
  import moment from '@/utils/moment'


  export default {
    data() {
      return {
        scrllViewRef: null,
        searchValue: '',
        inputStyles: {
          background: '#f8f8f8',
          borderRadius: '340rpx 340rpx 340rpx 340rpx',
          border: '1rpx solid #F1F2F3',
        },
        staticParams: {},
        options: {},
        halfColorButton,
        routerParams: {}
      }
    },
    onLoad(options) {
      this.options = options
      this.routerParams = getOptionsParams(options)
      Object.assign(this.staticParams, {
        mentalPatientPersonId: this.routerParams.id,
        time: this.routerParams.time
      })
      this.$refs.scrllViewRef.getList('init', this.staticParams)

      uni.$on('secondHandMobileAddNew', () => {
        this.staticParams.likeName = ''
        this.$refs.scrllViewRef.getList('init', this.staticParams)
      })
    },
    onUnload() {
      uni.$off('secondHandMobileAddNew')
    },
    methods: {
      moment,
      input(val) {
        Object.assign(this.staticParams, {
          likeName: this.searchValue ? this.searchValue.trim() : '',
        })
        this.$refs.scrllViewRef.getList('init', this.staticParams)
      },
      handleAdd() {
        navTo({
          url: '/itemRegistration/secondHandMobile/secondHandMobileAdd',
          params: {
            companyMessageId: this.options.companyMessageId
          }
        })
      },
      handleDetail(id) {
        navTo({
          url: '/itemRegistration/secondHandMobile/secondHandMobileDetail',
          params: {
            id
          }
        })
      },
      handleItem(item) {
        navTo({
          url: '/wristWatch/takeMedicineDetail',
          params: {
            ...item
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .root {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #F9F9F9;


    .top {
      padding: 25rpx;
      background: #FFFFFF;

      /deep/ .is-input-border {
        background: #F8F8F8 !important;
        border-radius: 340rpx 340rpx 340rpx 340rpx !important;
        border: 1rpx solid #F1F2F3 !important;
      }
    }



    .content {
      flex: 1;
      padding: 10rpx 15rpx;
      height: 0;
    }

    .bottom {
      height: 120rpx;
      background: #FFFFFF;
      border-radius: 0rpx 0rpx 0rpx 0rpx;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 24rpx;

      /deep/.u-button__text {
        font-weight: bold;
        font-size: 32rpx;
        color: #2488F5;
      }
    }

    .care-item {
      background: #FFFFFF;
      border-radius: 8rpx 8rpx 8rpx 8rpx;
      padding: 33rpx 42rpx 26rpx 42rpx;
      margin-bottom: 10rpx;

      .item-title {
        font-weight: bold;
        font-size: 32rpx;
        color: #000000;
        margin-bottom: 30rpx;
      }

      .item-i {
        display: flex;
        margin-bottom: 14rpx;

        .item-label {
          font-weight: 500;
          font-size: 28rpx;
          color: #A1A1A1;
          flex-shrink: 0;
        }

        .item-value {
          font-weight: bold;
          font-size: 28rpx;
          color: #333333;
          margin-left: 16rpx;
        }

      }
    }

    .bottom {}
  }
</style>